package com.dj.mingkong.portal.biz.repository.database.music;

import com.dj.mingkong.common.enums.MusicianStatusEnum;
import com.dj.mingkong.common.infrastructure.base.dto.query.QueryVo;
import com.dj.mingkong.common.infrastructure.base.repository.BaseDatabaseRepository;
import com.dj.mingkong.common.infrastructure.eo.database.music.MusicianEo;
import com.dj.mingkong.portal.biz.repository.database.music.mapper.MusicianMapper;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * 音乐人repository
 *
 * @author zenglonghui
 * @date: 2022/5/18 9:36
 */
@Repository
public class MusicianRepository extends BaseDatabaseRepository<MusicianMapper, MusicianEo, QueryVo> {
    public MusicianEo oneByUserId(Long userId) {
        return lambdaQuery()
                .eq(MusicianEo::getUserId, userId)
                .eq(MusicianEo::getStatus, MusicianStatusEnum.PASS.getIntVal())
                .one();
    }

    public boolean existByUserId(Long userId) {
        return lambdaQuery().eq(MusicianEo::getUserId, userId).exists();
    }

    public List<MusicianEo> listByUserId(Long userId) {
        return lambdaQuery().eq(MusicianEo::getUserId, userId).list();
    }
}
